|
|
 |
|
|
|
|
new_bend = MAX_BEND
Else
new_bend = bend
End If
DrawBranch new_bend, thickness - 1, _
Depth - 1, x1, y1, new_length, _
length_scale, rnd_scale, new_theta, _
dtheta, rnd_dtheta, max_branches
Next i
End If
End Sub |
|
|
|
|
|
|
|
|
Example program RndTree uses this subroutine to draw randomized trees. This program is similar to program BinTree2, but it also allows you to specify additional parameters for randomizing the tree. |
|
|
|
|
|
|
|
|
These programs only scratch the surface of approaches you can take to create more ''natural" trees. Real trees show endless variety. Some have long straight branches from which many side branches spring, and others have thick twisted branches. Some branches grow horizontally while others grow at an upward angle or are bent downward by their own weight. Using RndTree as a starting point, you can experiment with these and other variations to create different kinds of trees. |
|
|
|
|
|
|
|
|
The basic snowflake begins with an equilateral triangle like the one shown on the left in Figure 10.6. This triangle is called the curve's initiator. The program replaces each of the initiator's edges with a properly scaled and rotated version of the curve on the right in Figure 10.6. This curve is called the generator. |
|
|
|
|
|
|
|
|
The program then replaces each of the straight segments in the new figure with a smaller version of the generator. The program replaces the newer straight segments with smaller and smaller versions of the generator until it reaches the curve's desired depth. Figure 10.7 shows the snowflakes that result when the depth of recursion is 1, 2, and 3. |
|
|
|
|
|
|
|
|
To make creating new snowflakes easier, a program can store the coordinates of the points that make up the initiator in two arrays, InitiatorX and InitiatorY. It can store the amount by which it needs to turn to draw the segments that make up the generator in the array GeneratorDTheta. |
|
|
|
|
|
|
|
|
Figure 10.6
The initiator and generator for a snowflake. |
|
|
|
|
|